package com.matrix.java.chap_04;

import java.util.Scanner;

/*
    对三个城市排序
 */
public class Ex4_24 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter the first city: ");
        String city1 = input.next();
        System.out.print("Enter the second city: ");
        String city2 = input.next();
        System.out.print("Enter the third city: ");
        String city3 = input.next();
        String temp1 = city1;
        String temp2 = city2;
        int compare1 = city1.compareToIgnoreCase(city2);
        int compare2 = city1.compareToIgnoreCase(city3);
        int compare3 = city2.compareToIgnoreCase(city3);
        if (compare1 < 0 && compare2 < 0 && compare3 > 0) {
            city2 = city3;
            city3 = temp2;
        } else if (compare1 > 0 && compare2 < 0 && compare3 < 0) {
            city1 = temp2;
            city2 = temp1;
        } else if (compare1 < 0 && compare2 > 0 && compare3 < 0) {
            city1 = city3;
            city2 = temp1;
            city3 = temp2;
        } else if (compare1 > 0 && compare2 > 0 && compare3 < 0) {
            city1 = temp2;
            city2 = city3;
            city3 = temp1;
        } else if (compare1 > 0 && compare2 > 0 && compare3 > 0) {
            city1 = city3;
            city2 = temp2;
            city3 = temp1;
        }
        System.out.println(city1 + " " + city2 + " " + city3);
        input.close();
    }
}
